package com.fernfx.xingtan.my.ui;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.fernfx.xingtan.R;
import com.fernfx.xingtan.common.base.BaseActivity;
import com.fernfx.xingtan.common.pullrefresh.PullToRefreshActivity;

import java.util.Map;

import butterknife.OnClick;

/**
 * Created by admin on 2018/8/21.
 */

public class MyPrincipalActivity extends BaseActivity implements View.OnClickListener{

    public static void start(Context context) {
        Intent intent = new Intent(context, MyPrincipalActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_my_principal;
    }

    @Override
    protected void initView() {
        setToolbarTitle("我是盟主");
    }

    @OnClick({R.id.gain_profit_rlt,R.id.purchase_histroy_rlt,R.id.have_domain_rlt,R.id.return_domain_rlt})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.gain_profit_rlt:
                PullToRefreshActivity.start(mContext,new GainProfitCallback());
                break;
            case R.id.purchase_histroy_rlt:
                PullToRefreshActivity.start(mContext,new PurchaseHistroyCallback());
                break;
            case R.id.have_domain_rlt:
                PullToRefreshActivity.start(mContext,new HaveDomainCallback());
                break;
            case R.id.return_domain_rlt:
                PullToRefreshActivity.start(mContext,new ReturnDomainCallback());
                break;
        }
    }

    /*
     *分红明细
     */
    public class GainProfitCallback implements PullToRefreshActivity.CallBack{

        @Override
        public Map<String, Object> getRequestArgsMap() {
            requestArgsMap.clear();
            requestArgsMap.put("pageNo",1);
            requestArgsMap.put("pageSize",10);
            requestArgsMap.put("orderBy","create_time");
            requestArgsMap.put("order","desc");
            return requestArgsMap;
        }

        @Override
        public String getRequestUrl() {
            return "territory/getLeaderProfitList";
        }

        @Override
        public boolean getIsGet() {
            return true;
        }

        @Override
        public int getStatus() {
            return PullToRefreshActivity.MY_PRINCIPAL_STATUS;
        }

        @Override
        public String getTitle() {
            return "分红金额";
        }
    }

    /*
    *获取购买记录列表接口
    */
    public class PurchaseHistroyCallback implements PullToRefreshActivity.CallBack{

        @Override
        public Map<String, Object> getRequestArgsMap() {
            requestArgsMap.clear();
            requestArgsMap.put("pageNo",1);
            requestArgsMap.put("pageSize",10);
            requestArgsMap.put("orderBy","rent_out_time");
            requestArgsMap.put("order","desc");
            return requestArgsMap;
        }

        @Override
        public String getRequestUrl() {
            return "territory/getBuyInfoList";
        }

        @Override
        public boolean getIsGet() {
            return true;
        }

        @Override
        public int getStatus() {
            return PullToRefreshActivity.PURCHASE_HISTROY_STATUS;
        }

        @Override
        public String getTitle() {
            return "购买记录";
        }
    }

    /*
     *拥有领土
     */
    public class HaveDomainCallback implements PullToRefreshActivity.CallBack{

        @Override
        public Map<String, Object> getRequestArgsMap() {
            requestArgsMap.clear();
            requestArgsMap.put("pageNo",1);
            requestArgsMap.put("pageSize",10);
            requestArgsMap.put("orderBy","update_time");
            requestArgsMap.put("order","desc");
            return requestArgsMap;
        }

        @Override
        public String getRequestUrl() {
            return "territory/getMyTerritoryInfoList";
        }

        @Override
        public boolean getIsGet() {
            return true;
        }

        @Override
        public int getStatus() {
            return PullToRefreshActivity.HAVE_DOMAIN_STATUS;
        }

        @Override
        public String getTitle() {
            return "拥有的领土";
        }
    }

    /*
     *退还的领土
     */
    public class ReturnDomainCallback implements PullToRefreshActivity.CallBack{

        @Override
        public Map<String, Object> getRequestArgsMap() {
            requestArgsMap.clear();
            requestArgsMap.put("pageNo",1);
            requestArgsMap.put("pageSize",10);
            requestArgsMap.put("orderBy","throw_lease_time");
            requestArgsMap.put("order","desc");
            return requestArgsMap;
        }

        @Override
        public String getRequestUrl() {
            return "territory/getTerritoryReturnInfoList";
        }

        @Override
        public boolean getIsGet() {
            return true;
        }

        @Override
        public int getStatus() {
            return PullToRefreshActivity.RETRUN_DOMAIN_STATUS;
        }

        @Override
        public String getTitle() {
            return "退还的领土";
        }
    }
}
